package com.example.jn_dxs.Ui.fragment;

import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.example.jn_dxs.Base.BaseFragment;
import com.example.jn_dxs.Base.BaseViewModel;
import com.example.jn_dxs.R;
import com.example.jn_dxs.Ui.activity.SearchActivity;
import com.example.jn_dxs.Ui.activity.SingleWellWaterLevelActivity;
import com.example.jn_dxs.Ui.activity.SingleWellWaterTemperatureActivity;
import com.example.jn_dxs.Ui.activity.WaterLevelStatisticsActivity;
import com.example.jn_dxs.Ui.activity.WaterLevelTrendActivity;
import com.example.jn_dxs.Ui.activity.WaterTemperatureTableActivity;
import com.example.jn_dxs.Ui.activity.WaterTemperatureTrendActivity;
import com.example.jn_dxs.databinding.FragmentDemandBinding;
import com.example.jn_dxs.databinding.FragmentMapBinding;

public class DemandFragment extends BaseFragment<BaseViewModel, FragmentDemandBinding> {
    private Animation arrowDown, arrowUp;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_demand;
    }

    @Override
    protected void loadData() {
        binding.MyTopBar.tvTitle.setText("查询");
        binding.MyTopBar.tvBack.setVisibility(View.GONE);

        arrowDown = AnimationUtils.loadAnimation(getContext(), R.anim.arrow_demand_down);
        arrowUp = AnimationUtils.loadAnimation(getContext(), R.anim.arrow_demand_up);

        binding.waterTemperature.setOnClickListener(v -> {
            if (binding.WaterTemperatureMenu.getVisibility() == View.VISIBLE) {
                binding.WaterTemperatureMenu.setVisibility(View.GONE);
                binding.waterTemperatureIV.startAnimation(arrowUp);
            } else {
                binding.WaterTemperatureMenu.setVisibility(View.VISIBLE);
                binding.waterTemperatureIV.startAnimation(arrowDown);
            }

        });

        binding.WaterLevel.setOnClickListener(v -> {

            if (binding.WaterLevelIVMenu.getVisibility() == View.VISIBLE) {
                binding.WaterLevelIVMenu.setVisibility(View.GONE);
                binding.WaterLevelIV.startAnimation(arrowUp);
            } else {
                binding.WaterLevelIVMenu.setVisibility(View.VISIBLE);
                binding.WaterLevelIV.startAnimation(arrowDown);
            }
        });
        binding.SingleWellWaterTemperature.setOnClickListener(v -> {
            //单井水温
//            startActivity(new Intent(getContext(), SingleWellWaterTemperatureActivity.class));
            startActivity(new Intent(getContext(), SearchActivity.class).putExtra("type",1));
        });
        binding.WaterTemperatureTable.setOnClickListener(v -> {
            //水温统计
//            startActivity(new Intent(getContext(), WaterTemperatureTableActivity.class));
            startActivity(new Intent(getContext(), SearchActivity.class).putExtra("type",2));
        });
        binding.WaterTemperatureTrend.setOnClickListener(v -> {
            //水温趋势
//            startActivity(new Intent(getContext(), WaterTemperatureTrendActivity.class));
            startActivity(new Intent(getContext(), SearchActivity.class).putExtra("type",3));

        });
        binding.SingleWellWaterLevel.setOnClickListener(v -> {
            //单井水位
//            startActivity(new Intent(getContext(), SingleWellWaterLevelActivity.class));
            startActivity(new Intent(getContext(), SearchActivity.class).putExtra("type",4));
        });
        binding.WaterTable.setOnClickListener(v -> {
            //水位统计
//            startActivity(new Intent(getContext(), WaterLevelStatisticsActivity.class));
            startActivity(new Intent(getContext(), SearchActivity.class).putExtra("type",5));
        });
        binding.WaterLevelTrend.setOnClickListener(v -> {
            //水位趋势
//            startActivity(new Intent(getContext(), WaterLevelTrendActivity.class));
            startActivity(new Intent(getContext(), SearchActivity.class).putExtra("type",6));
        });
    }
}
